#!/usr/bin/env python
# coding: utf-8
from matplotlib.pyplot import *

fin=open('time_err.dat')
fin2=open('time_err_n3.dat')
todo=fin.read().split('\n')
todo2=fin2.read().split('\n')
xs=[float(x.split()[0]) for x in todo if x]
ys=[float(x.split()[1]) for x in todo if x]
ys2=[float(x.split()[1]) for x in todo2 if x]
yerr=[float(x.split()[2]) for x in todo if x]
yerr2=[float(x.split()[2]) for x in todo2 if x]
diff=reduce(lambda x,y:x+y, [ys2[i]/ys[i] for i in range(len(ys))], 0)/len(ys)
title("Comparacion de strassen vs algoritmo en $cw$")
xlabel("Cantidad de Personas")
ylabel("Tiempo de ejecucion (s)")
errorbar(xs,ys,yerr,marker='_',color='k',ls='None',label="Strassen con umbral=4")
errorbar(xs,ys2,yerr2,marker='_',color='b',ls='None',label="Algoritmo tradicional")
legend(loc="upper left")
#text(1,.06,"en promedio,\nalgoritmo_cubico/strassen="+str("%.3f"%diff))
savefig('ej3_times_vs.png',dpi=640./8)
show()
